#! /bin/bash
export LANG=zh_CN.UTF-8
MYSQL_HOME=/usr/bin/mysql

${MYSQL_HOME} -h 192.168.88.80 -P 3306 -u root -p123456 -e "

-- 稽核上层表数据量
select 1/count(*) from edu_check.ydh_rpt_studying_timecnt_tmp;
select 1/count(*) from edu_check.ydh_rpt_late_timecnt_tmp;
select 1/count(*) from edu_check.ydh_rpt_leave_timecnt_tmp;
select 1/count(*) from edu_check.ydh_rpt_truant_timecnt_tmp;

truncate table edu_check.ydh_rpt_studying_timecnt;
insert into edu_check.ydh_rpt_studying_timecnt select CREATE_DATE, CLASS_ID, TIME_TYPE, DT, STUDYING_CNT, STUDYING_PCT
from edu_check.ydh_rpt_studying_timecnt_tmp;

truncate table edu_check.ydh_rpt_late_timecnt;
insert into edu_check.ydh_rpt_late_timecnt select CREATE_DATE, CLASS_ID, TIME_TYPE, DT, LATE_CNT, LATE_PCT
from edu_check.ydh_rpt_late_timecnt_tmp;

truncate table edu_check.ydh_rpt_leave_timecnt;
insert into edu_check.ydh_rpt_leave_timecnt select CREATE_DATE, CLASS_ID, TIME_TYPE, DT, LEAVE_CNT, LEAVE_PCT
from edu_check.ydh_rpt_leave_timecnt_tmp;

truncate table edu_check.ydh_rpt_truant_timecnt;
insert into edu_check.ydh_rpt_truant_timecnt select CREATE_DATE, CLASS_ID, TIME_TYPE, DT, TRUANT_CNT, TRUANT_PCT
from edu_check.ydh_rpt_truant_timecnt_tmp;
"
a=$?
if [ ${a} -eq 0 ];then 
	echo 'Program running status return code:' ${a}
	echo '=============================打完收工！================================='
else 
	echo 'Program running status return code:' ${a}
	echo '=============================程序出BUG咯！=============================='
	fi